﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SalesSys.DAL.Base;

namespace SalesSys.DAL.Models
{
    /// <summary>
    /// 商品
    /// </summary>
    public class Commodity : DbEntityBase<Guid>
    {
        /// <summary>
        /// 记录时间
        /// </summary>
        public DateTime RecordTime { get; set; }

        /// <summary>
        /// 创建人
        /// </summary>
        public virtual Employee Creater { get; set; }

        /// <summary>
        /// 供应商
        /// </summary>
        public virtual Supplier Supplier { get; set; }


        public string FillName()
        {
            return Brand + "/" + Name + "/" + Standard + "/" + Format;
        }

        /// <summary>
        /// 商品品牌，是对Supplier.Brand的冗余
        /// </summary>
        public string Brand { get; set; }

        /// <summary>
        /// 类型,螺纹、盘圆、螺盘、钢坯
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// 性能，300E
        /// </summary>
        public string Standard { get; set; }
        /// <summary>
        /// 规格,直径10mm,9米
        /// </summary>
        public string Format { get; set; }

        /// <summary>
        /// 商品单重，t
        /// </summary>
        [DecimalPrecision(18, 3)]
        public decimal Weight { get; set; }
        //[Obsolete]
        //public decimal Price { get; set; }
        //[Obsolete]
        ///// <summary>
        ///// 与基价差
        ///// </summary>
        //public decimal PriceDifference { get; set; }
        ///// <summary>
        ///// 库存，千克
        ///// </summary>
        //[Obsolete]
        //public decimal Amount { get; set; }


        public class Mapper : SalMapper<Commodity, Guid>
        {
            Mapper()
            {
                HasOptional(p => p.Creater);
                HasOptional(p => p.Supplier);
                //   Property(p => p.Brand).HasMaxLength(50);
                Property(p => p.Name).HasMaxLength(50);
                Property(p => p.Standard).HasMaxLength(50);
                Property(p => p.Format).HasMaxLength(50);

            }
        }

    }
}
